package com.general.framework.qinyi.event;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

@Component
public class PushEventPublisher {
    private final ApplicationContext applicationContext;
    private final ApplicationEventPublisher eventPublisher;

    public PushEventPublisher(ApplicationContext applicationContext, ApplicationEventPublisher eventPublisher) {
        this.applicationContext = applicationContext;
        this.eventPublisher = eventPublisher;
    }

    public void publish(PushEventMessage message) {
        applicationContext.publishEvent(new PushEvent(message));
        eventPublisher.publishEvent(new PushEvent(message));
    }
}
